package com.zero.zutils
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;

	public class UiUtils
	{
		
		public static function addToDisplay($childObject:Object, $parentObject:Object):void
		{
			if($childObject && $childObject.parent && $parentObject)
			{
				$childObject.parent.removeChild($childObject);
				$parentObject.addChild($childObject);
			}
			else if($childObject && $parentObject)
			{
				$parentObject.addChild($childObject);
			}
			else
			{
				//
			}
		}
		
		public static function removeFromDisplay($childObject:Object):void
		{
			if($childObject && $childObject.parent)
			{
				$childObject.parent.removeChild($childObject);
			}
		}
		
		public static function disposeAllChildren($target:DisplayObjectContainer):void
		{
			if($target == null)return;
			while($target.numChildren > 0)
			{
				var child:DisplayObject=$target.getChildAt(0);
				child.parent.removeChild(child);
				child = null;
			}
		}
	}
}